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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.r: C = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.r: C = None
        self.txt = txt

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

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

d.u = e
d.t = e
b.p = e
b.u = e
b.r = e
e.y = d
i.p = e
i.u = e
i.r = e
assert d.t.y.t.txt == "e"