class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

b = A("b")
l = B("l")
f = C("f")
d = D("d")
g = C("g")
i = D("i")
e = A("e")
j = B("j")

b.x = i
l.z = g
l.u = f
f.q = g
f.v = l
d.x = j
g.q = f
g.v = j
i.x = l
e.x = d
j.z = g
j.u = g
assert l.u.q.q.v.z.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

b = A("b")
l = B("l")
f = C("f")
d = D("d")
g = C("g")
i = D("i")
e = A("e")
j = B("j")

b.x = i
l.z = g
l.u = f
f.q = g
f.v = l
d.x = j
g.q = f
g.v = j
i.x = l
e.x = d
j.z = g
j.u = g
assert l.u.q.q.v.z.q.q.txt == "g"