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

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

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

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

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

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

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

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

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

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

i.z = c
i.r = g
m.s = i
m.y = c
m.x = c
m.o = j
c.t = m
j.z = c
j.o = c
j.q = i
j.t = i
l.z = c
l.r = g
g.z = c
g.r = l
assert c.t.s.z.t.o.z.txt == "c"