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

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

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

c = A("c")
n = B("n")
b = C("b")
m = B("m")
k = C("k")

c.x = k
n.p = m
n.x = m
n.t = c
b.x = n
m.p = n
m.x = n
m.t = c
k.x = n
assert n.t.x.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
b = C("b")
m = B("m")
k = C("k")

c.x = k
n.p = m
n.x = m
n.t = c
b.x = n
m.p = n
m.x = n
m.t = c
k.x = n
assert n.t.x.x.t.x.txt == "k"