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

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

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

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

c = A("c")
g = B("g")
m = C("m")
l = D("l")
i = A("i")

c.z = i
c.x = m
c.q = m
g.u = l
g.w = m
m.t = c
m.o = l
l.y = i
l.x = c
i.z = c
i.x = m
i.q = m
assert l.y.z.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: C = None
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
m = C("m")
l = D("l")
i = A("i")

c.z = i
c.x = m
c.q = m
g.u = l
g.w = m
m.t = c
m.o = l
l.y = i
l.x = c
i.z = c
i.x = m
i.q = m
assert l.y.z.x.t.txt == "c"