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

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

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

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

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

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

g.t = d
k.x = d
k.u = d
c.x = k
c.u = k
b.t = d
a.t = d
d.x = c
d.u = c
h.t = k
j.t = k
i.x = k
i.u = c
m.t = d
assert k.u.u.x.x.u.u.x.u.txt == "c"