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

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

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

a = A("a")
l = B("l")
g = C("g")
k = C("k")
f = B("f")
c = A("c")
h = B("h")
i = B("i")
d = A("d")

a.r = k
l.y = i
g.x = k
g.t = h
k.x = g
k.t = h
f.y = i
c.r = g
h.y = l
i.y = f
d.r = g
assert a.r.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
g = C("g")
k = C("k")
f = B("f")
c = A("c")
h = B("h")
i = B("i")
d = A("d")

a.r = k
l.y = i
g.x = k
g.t = h
k.x = g
k.t = h
f.y = i
c.r = g
h.y = l
i.y = f
d.r = g
assert a.r.x.x.x.x.txt == "k"