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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.txt = txt

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

l = A("l")
a = B("a")
h = C("h")
g = B("g")
n = C("n")
b = B("b")
j = A("j")

l.u = j
l.y = j
a.q = b
a.o = h
h.t = j
g.q = a
g.o = h
n.t = j
b.q = a
b.o = h
j.u = l
j.y = l
assert n.t.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.txt = txt

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

l = A("l")
a = B("a")
h = C("h")
g = B("g")
n = C("n")
b = B("b")
j = A("j")

l.u = j
l.y = j
a.q = b
a.o = h
h.t = j
g.q = a
g.o = h
n.t = j
b.q = a
b.o = h
j.u = l
j.y = l
assert n.t.y.y.u.txt == "l"