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

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

d = A("d")
i = B("i")
l = B("l")
g = B("g")
c = A("c")
j = A("j")
f = B("f")

d.z = f
d.p = c
i.z = j
i.t = l
l.z = c
l.t = g
g.z = c
g.t = f
c.z = l
c.p = d
j.z = l
j.p = c
f.z = c
f.t = i
assert j.z.z.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

d = A("d")
i = B("i")
l = B("l")
g = B("g")
c = A("c")
j = A("j")
f = B("f")

d.z = f
d.p = c
i.z = j
i.t = l
l.z = c
l.t = g
g.z = c
g.t = f
c.z = l
c.p = d
j.z = l
j.p = c
f.z = c
f.t = i
assert j.z.z.z.t.z.txt == "c"