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

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

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

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

h.p = i
c.w = d
c.u = d
i.t = a
i.u = c
a.p = i
d.w = c
d.u = c
f.w = c
f.u = c
assert a.p.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

h.p = i
c.w = d
c.u = d
i.t = a
i.u = c
a.p = i
d.w = c
d.u = c
f.w = c
f.u = c
assert a.p.t.p.t.p.txt == "i"