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

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

b = A("b")
k = B("k")
j = B("j")
g = A("g")
f = B("f")
c = B("c")
d = B("d")

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

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

b = A("b")
k = B("k")
j = B("j")
g = A("g")
f = B("f")
c = B("c")
d = B("d")

b.p = j
b.z = g
k.y = c
k.t = b
j.y = d
j.t = g
g.p = k
g.z = b
f.y = c
f.t = b
c.y = j
c.t = b
d.y = j
d.t = g
assert j.y.t.z.z.txt == "g"