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

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

f = A("f")
k = B("k")
c = B("c")
n = A("n")
a = B("a")

f.t = k
k.r = c
k.t = c
c.r = a
c.t = k
n.t = c
a.r = k
a.t = c
assert a.r.t.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: B = None
        self.t: B = None
        self.txt = txt

f = A("f")
k = B("k")
c = B("c")
n = A("n")
a = B("a")

f.t = k
k.r = c
k.t = c
c.r = a
c.t = k
n.t = c
a.r = k
a.t = c
assert a.r.t.t.r.txt == "c"