class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: B = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: D = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
f = C("f")
h = D("h")
a = C("a")
g = B("g")
c = C("c")

b.p = h
b.s = c
b.q = j
b.z = j
j.s = b
j.p = h
f.o = a
h.y = c
h.z = c
h.u = b
a.o = f
g.s = b
g.p = h
c.o = f
assert f.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: B = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: D = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
f = C("f")
h = D("h")
a = C("a")
g = B("g")
c = C("c")

b.p = h
b.s = c
b.q = j
b.z = j
j.s = b
j.p = h
f.o = a
h.y = c
h.z = c
h.u = b
a.o = f
g.s = b
g.p = h
c.o = f
assert f.o.o.o.o.o.txt == "a"