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

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

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

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

a = A("a")
e = B("e")
g = C("g")
b = D("b")

a.t = e
e.v = b
e.q = g
e.r = g
e.u = a
g.o = e
b.o = e
assert e.v.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
g = C("g")
b = D("b")

a.t = e
e.v = b
e.q = g
e.r = g
e.u = a
g.o = e
b.o = e
assert e.v.o.v.o.txt == "e"