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.txt = txt

n = A("n")
l = B("l")
c = C("c")
g = B("g")
b = C("b")
k = C("k")
j = B("j")

n.t = l
l.r = n
c.r = b
g.r = n
b.r = k
k.r = c
j.r = n
assert j.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.txt = txt

n = A("n")
l = B("l")
c = C("c")
g = B("g")
b = C("b")
k = C("k")
j = B("j")

n.t = l
l.r = n
c.r = b
g.r = n
b.r = k
k.r = c
j.r = n
assert j.r.t.r.txt == "n"