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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: C = None
        self.u: B = None
        self.o: C = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: C = None
        self.u: B = None
        self.o: C = None
        self.txt = txt

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

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

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

f.p = a
f.u = b
f.y = b
f.q = c
d.z = b
d.v = b
d.o = b
d.u = a
b.y = f
c.o = f
c.q = b
e.o = f
e.q = b
a.z = b
a.v = b
a.o = b
a.u = d
assert f.q.q.y.p.z.y.txt == "f"