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

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

b = A("b")
h = B("h")
i = B("i")
n = A("n")
j = B("j")
g = A("g")
d = A("d")
l = A("l")
k = B("k")
m = A("m")

b.y = i
b.z = j
h.p = k
i.p = h
n.y = j
n.z = i
j.p = i
g.y = h
g.z = i
d.y = i
d.z = i
l.y = h
l.z = j
k.p = h
m.y = i
m.z = i
assert k.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.txt = txt

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

b = A("b")
h = B("h")
i = B("i")
n = A("n")
j = B("j")
g = A("g")
d = A("d")
l = A("l")
k = B("k")
m = A("m")

b.y = i
b.z = j
h.p = k
i.p = h
n.y = j
n.z = i
j.p = i
g.y = h
g.z = i
d.y = i
d.z = i
l.y = h
l.z = j
k.p = h
m.y = i
m.z = i
assert k.p.p.p.p.txt == "k"