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

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

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

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

e = A("e")
i = B("i")
d = C("d")
b = D("b")

e.t = i
i.t = b
i.r = d
i.y = d
d.q = i
d.r = i
d.z = b
b.u = e
b.v = d
b.q = i
assert e.t.r.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

e = A("e")
i = B("i")
d = C("d")
b = D("b")

e.t = i
i.t = b
i.r = d
i.y = d
d.q = i
d.r = i
d.z = b
b.u = e
b.v = d
b.q = i
assert e.t.r.r.t.txt == "b"