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

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

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

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

l = A("l")
h = B("h")
j = C("j")
c = D("c")
d = C("d")
g = B("g")

l.u = g
l.x = g
h.z = l
j.q = l
j.y = l
c.o = d
c.t = l
c.x = l
c.u = j
d.q = l
d.y = l
g.z = l
assert c.x.u.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

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

l = A("l")
h = B("h")
j = C("j")
c = D("c")
d = C("d")
g = B("g")

l.u = g
l.x = g
h.z = l
j.q = l
j.y = l
c.o = d
c.t = l
c.x = l
c.u = j
d.q = l
d.y = l
g.z = l
assert c.x.u.z.x.z.txt == "l"