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

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

k = A("k")
d = B("d")
m = A("m")
b = B("b")
e = B("e")
n = B("n")

k.y = m
k.t = n
d.x = n
m.y = k
m.t = b
b.x = d
e.x = b
n.x = d
assert n.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
m = A("m")
b = B("b")
e = B("e")
n = B("n")

k.y = m
k.t = n
d.x = n
m.y = k
m.t = b
b.x = d
e.x = b
n.x = d
assert n.x.x.x.x.x.txt == "d"