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

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

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

l = A("l")
j = B("j")
h = C("h")
f = B("f")
i = A("i")
g = C("g")

l.v = g
l.z = i
j.v = h
j.t = h
j.p = f
h.x = g
f.v = h
f.t = h
f.p = j
i.v = g
i.z = l
g.x = h
assert g.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
h = C("h")
f = B("f")
i = A("i")
g = C("g")

l.v = g
l.z = i
j.v = h
j.t = h
j.p = f
h.x = g
f.v = h
f.t = h
f.p = j
i.v = g
i.z = l
g.x = h
assert g.x.x.x.x.x.txt == "h"