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

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

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

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

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

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

c.t = d
c.x = m
b.t = g
b.r = i
g.t = c
g.x = i
m.t = d
m.r = b
i.t = g
i.r = b
j.t = g
j.r = b
h.t = l
h.x = m
l.t = g
l.x = i
d.t = g
d.x = j
assert h.t.t.t.x.r.t.t.x.r.txt == "b"