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

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

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

a = A("a")
f = B("f")
c = C("c")
n = B("n")
d = A("d")
k = A("k")
b = A("b")
l = B("l")
j = C("j")

a.t = n
f.r = a
c.r = j
c.x = d
c.y = n
n.r = a
d.t = f
k.t = n
b.t = n
l.r = k
j.r = c
j.x = b
j.y = l
assert c.y.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
c = C("c")
n = B("n")
d = A("d")
k = A("k")
b = A("b")
l = B("l")
j = C("j")

a.t = n
f.r = a
c.r = j
c.x = d
c.y = n
n.r = a
d.t = f
k.t = n
b.t = n
l.r = k
j.r = c
j.x = b
j.y = l
assert c.y.r.t.r.txt == "a"