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

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

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

l = A("l")
g = B("g")
j = C("j")
n = C("n")
a = B("a")
d = B("d")
k = A("k")
h = C("h")

l.z = j
l.w = k
g.p = l
j.z = k
n.z = l
a.p = l
d.p = k
k.z = j
k.w = l
h.z = l
assert n.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: A = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
j = C("j")
n = C("n")
a = B("a")
d = B("d")
k = A("k")
h = C("h")

l.z = j
l.w = k
g.p = l
j.z = k
n.z = l
a.p = l
d.p = k
k.z = j
k.w = l
h.z = l
assert n.z.z.z.txt == "k"