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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
e = D("e")
c = E("c")

b.r = h
b.x = h
b.t = c
b.o = c
f.u = e
h.y = f
e.o = b
e.x = b
e.t = h
e.q = c
c.z = f
c.p = f
assert h.y.u.t.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: E = None
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: B = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
e = D("e")
c = E("c")

b.r = h
b.x = h
b.t = c
b.o = c
f.u = e
h.y = f
e.o = b
e.x = b
e.t = h
e.q = c
c.z = f
c.p = f
assert h.y.u.t.y.u.txt == "e"