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

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

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

h = A("h")
m = B("m")
n = C("n")
e = A("e")
f = A("f")
c = C("c")
k = A("k")

h.t = m
m.p = e
m.r = f
m.x = n
n.u = c
n.t = m
n.q = m
e.t = m
f.t = m
c.u = n
c.t = m
c.q = m
k.t = m
assert f.t.p.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.p: A = None
        self.r: A = None
        self.x: C = None
        self.txt = txt

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

h = A("h")
m = B("m")
n = C("n")
e = A("e")
f = A("f")
c = C("c")
k = A("k")

h.t = m
m.p = e
m.r = f
m.x = n
n.u = c
n.t = m
n.q = m
e.t = m
f.t = m
c.u = n
c.t = m
c.q = m
k.t = m
assert f.t.p.t.r.txt == "f"