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

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

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

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

f = A("f")
c = B("c")
d = C("d")
b = D("b")
a = D("a")
j = A("j")
m = C("m")

f.y = d
f.o = j
c.r = d
c.z = b
d.r = m
d.o = m
d.q = c
d.t = c
b.r = c
a.r = c
j.y = m
j.o = f
m.r = d
m.o = d
m.q = c
m.t = c
assert d.o.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: A = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
d = C("d")
b = D("b")
a = D("a")
j = A("j")
m = C("m")

f.y = d
f.o = j
c.r = d
c.z = b
d.r = m
d.o = m
d.q = c
d.t = c
b.r = c
a.r = c
j.y = m
j.o = f
m.r = d
m.o = d
m.q = c
m.t = c
assert d.o.t.r.t.txt == "c"