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

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

m = A("m")
d = B("d")
c = B("c")
i = B("i")
g = B("g")
j = A("j")
f = A("f")
b = B("b")
a = A("a")

m.t = i
m.x = a
d.p = j
c.p = j
i.p = m
g.p = m
j.t = d
j.x = a
f.t = i
f.x = m
b.p = f
a.t = i
a.x = f
assert b.p.t.p.t.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: A = None
        self.txt = txt

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

m = A("m")
d = B("d")
c = B("c")
i = B("i")
g = B("g")
j = A("j")
f = A("f")
b = B("b")
a = A("a")

m.t = i
m.x = a
d.p = j
c.p = j
i.p = m
g.p = m
j.t = d
j.x = a
f.t = i
f.x = m
b.p = f
a.t = i
a.x = f
assert b.p.t.p.t.p.x.txt == "a"