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

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

c = A("c")
m = B("m")
a = A("a")
g = B("g")
e = B("e")
j = B("j")
i = A("i")
f = A("f")
h = A("h")

c.o = i
m.q = f
m.t = f
a.o = f
g.q = i
g.t = h
e.q = i
e.t = a
j.q = i
j.t = f
i.o = a
f.o = h
h.o = a
assert e.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

c = A("c")
m = B("m")
a = A("a")
g = B("g")
e = B("e")
j = B("j")
i = A("i")
f = A("f")
h = A("h")

c.o = i
m.q = f
m.t = f
a.o = f
g.q = i
g.t = h
e.q = i
e.t = a
j.q = i
j.t = f
i.o = a
f.o = h
h.o = a
assert e.t.o.o.txt == "h"