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

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

g = A("g")
n = B("n")
j = A("j")
b = B("b")
e = A("e")
d = A("d")

g.z = n
n.x = b
j.z = n
b.x = n
e.z = n
d.z = b
assert e.z.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

g = A("g")
n = B("n")
j = A("j")
b = B("b")
e = A("e")
d = A("d")

g.z = n
n.x = b
j.z = n
b.x = n
e.z = n
d.z = b
assert e.z.x.x.txt == "n"