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

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

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

l = A("l")
m = B("m")
c = C("c")
g = A("g")
d = B("d")
k = B("k")
a = A("a")
b = C("b")

l.t = g
l.p = b
l.r = c
m.v = g
m.t = d
c.u = k
c.q = m
c.t = b
g.t = a
g.p = b
g.r = c
d.v = g
d.t = m
k.v = a
k.t = d
a.t = l
a.p = c
a.r = b
b.u = m
b.q = m
b.t = c
assert l.t.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: C = None
        self.r: C = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
c = C("c")
g = A("g")
d = B("d")
k = B("k")
a = A("a")
b = C("b")

l.t = g
l.p = b
l.r = c
m.v = g
m.t = d
c.u = k
c.q = m
c.t = b
g.t = a
g.p = b
g.r = c
d.v = g
d.t = m
k.v = a
k.t = d
a.t = l
a.p = c
a.r = b
b.u = m
b.q = m
b.t = c
assert l.t.t.p.t.txt == "b"