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

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

m = A("m")
h = B("h")
d = B("d")
i = A("i")
k = A("k")
j = A("j")

m.z = i
m.t = h
h.s = d
h.o = d
d.s = h
d.o = h
i.z = m
i.t = h
k.z = j
k.t = d
j.z = i
j.t = d
assert h.o.o.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: B = None
        self.txt = txt

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

m = A("m")
h = B("h")
d = B("d")
i = A("i")
k = A("k")
j = A("j")

m.z = i
m.t = h
h.s = d
h.o = d
d.s = h
d.o = h
i.z = m
i.t = h
k.z = j
k.t = d
j.z = i
j.t = d
assert h.o.o.s.s.txt == "h"