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

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

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

i = A("i")
l = B("l")
a = C("a")
h = A("h")
d = B("d")

i.u = d
l.x = d
a.y = i
a.r = d
a.t = h
h.u = l
d.x = l
assert i.u.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

i = A("i")
l = B("l")
a = C("a")
h = A("h")
d = B("d")

i.u = d
l.x = d
a.y = i
a.r = d
a.t = h
h.u = l
d.x = l
assert i.u.x.x.txt == "d"