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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

c = A("c")
b = B("b")
l = C("l")
g = D("g")
f = C("f")
a = D("a")
d = B("d")
n = A("n")
m = C("m")

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

c = A("c")
b = B("b")
l = C("l")
g = D("g")
f = C("f")
a = D("a")
d = B("d")
n = A("n")
m = C("m")

c.p = m
c.u = b
b.t = n
b.v = d
l.x = g
g.r = a
f.x = g
a.r = g
d.t = c
d.v = b
n.p = f
n.u = d
m.x = a
assert c.p.x.r.r.r.r.r.r.r.txt == "g"