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

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

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

n = A("n")
b = B("b")
m = C("m")
l = A("l")
g = C("g")
e = C("e")
a = C("a")
c = B("c")
i = C("i")
j = C("j")

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

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

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

n = A("n")
b = B("b")
m = C("m")
l = A("l")
g = C("g")
e = C("e")
a = C("a")
c = B("c")
i = C("i")
j = C("j")

n.p = b
b.t = c
b.v = j
b.x = n
m.x = l
m.r = e
l.p = b
g.x = n
g.r = m
e.x = l
e.r = g
a.x = n
a.r = j
c.t = b
c.v = i
c.x = l
i.x = l
i.r = j
j.x = n
j.r = e
assert g.r.r.r.x.p.t.t.t.v.r.txt == "j"