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

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

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

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

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

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

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

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

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