class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: C = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.u: B = None
        self.txt = txt

g = A("g")
a = B("a")
c = C("c")
f = D("f")
n = C("n")
j = D("j")
i = B("i")

g.v = j
g.u = n
g.p = n
a.t = g
c.p = g
f.q = i
f.p = g
f.u = a
n.p = g
j.q = a
j.p = g
j.u = i
i.t = g
assert n.p.v.p.v.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: C = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.u: B = None
        self.txt = txt

g = A("g")
a = B("a")
c = C("c")
f = D("f")
n = C("n")
j = D("j")
i = B("i")

g.v = j
g.u = n
g.p = n
a.t = g
c.p = g
f.q = i
f.p = g
f.u = a
n.p = g
j.q = a
j.p = g
j.u = i
i.t = g
assert n.p.v.p.v.u.t.u.txt == "n"