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

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

i = A("i")
g = B("g")
a = A("a")
l = B("l")
c = A("c")
n = A("n")
b = B("b")
f = A("f")
k = A("k")
e = B("e")

i.r = e
i.t = n
g.v = b
g.r = c
a.r = b
a.t = c
l.v = g
l.r = n
c.r = b
c.t = a
n.r = g
n.t = f
b.v = l
b.r = a
f.r = l
f.t = n
k.r = g
k.t = n
e.v = l
e.r = n
assert a.r.v.v.r.r.v.r.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

i = A("i")
g = B("g")
a = A("a")
l = B("l")
c = A("c")
n = A("n")
b = B("b")
f = A("f")
k = A("k")
e = B("e")

i.r = e
i.t = n
g.v = b
g.r = c
a.r = b
a.t = c
l.v = g
l.r = n
c.r = b
c.t = a
n.r = g
n.t = f
b.v = l
b.r = a
f.r = l
f.t = n
k.r = g
k.t = n
e.v = l
e.r = n
assert a.r.v.v.r.r.v.r.r.v.txt == "b"