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

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

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

l = A("l")
f = B("f")
d = C("d")
a = C("a")

l.t = f
l.u = d
f.s = a
f.y = l
f.u = d
d.y = a
d.t = a
d.p = l
a.y = d
a.t = d
a.p = l
assert f.y.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
d = C("d")
a = C("a")

l.t = f
l.u = d
f.s = a
f.y = l
f.u = d
d.y = a
d.t = a
d.p = l
a.y = d
a.t = d
a.p = l
assert f.y.u.p.u.txt == "d"