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

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

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

e = A("e")
f = B("f")
m = C("m")
l = C("l")
h = C("h")
i = A("i")
k = B("k")

e.t = i
e.v = i
f.p = l
f.x = l
f.r = k
m.x = k
m.y = l
l.x = k
l.y = m
h.x = f
h.y = m
i.t = e
i.v = e
k.p = m
k.x = m
k.r = f
assert h.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
m = C("m")
l = C("l")
h = C("h")
i = A("i")
k = B("k")

e.t = i
e.v = i
f.p = l
f.x = l
f.r = k
m.x = k
m.y = l
l.x = k
l.y = m
h.x = f
h.y = m
i.t = e
i.v = e
k.p = m
k.x = m
k.r = f
assert h.x.x.x.x.x.txt == "k"