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

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

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

k = A("k")
h = B("h")
j = C("j")
b = B("b")
f = B("f")
a = C("a")
d = A("d")
e = A("e")
g = B("g")

k.p = d
h.u = b
j.v = f
b.u = g
f.u = h
a.v = b
d.p = e
e.p = k
g.u = h
assert d.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
j = C("j")
b = B("b")
f = B("f")
a = C("a")
d = A("d")
e = A("e")
g = B("g")

k.p = d
h.u = b
j.v = f
b.u = g
f.u = h
a.v = b
d.p = e
e.p = k
g.u = h
assert d.p.p.p.p.p.txt == "k"