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

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

i = A("i")
l = B("l")
g = B("g")
k = A("k")
a = A("a")
d = A("d")

i.r = d
i.u = l
l.t = a
l.o = g
g.t = k
g.o = l
k.r = a
k.u = g
a.r = i
a.u = g
d.r = a
d.u = g
assert k.r.r.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

i = A("i")
l = B("l")
g = B("g")
k = A("k")
a = A("a")
d = A("d")

i.r = d
i.u = l
l.t = a
l.o = g
g.t = k
g.o = l
k.r = a
k.u = g
a.r = i
a.u = g
d.r = a
d.u = g
assert k.r.r.u.o.txt == "g"