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

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

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

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

m = A("m")
n = B("n")
l = C("l")
f = D("f")
e = C("e")
j = D("j")
i = A("i")
c = B("c")

m.p = i
m.u = i
m.r = i
n.w = m
n.x = c
n.p = i
l.p = e
l.q = e
l.x = e
l.r = f
f.v = j
e.p = l
e.q = l
e.x = l
e.r = f
j.v = f
i.p = m
i.u = m
i.r = m
c.w = i
c.x = n
c.p = m
assert l.q.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: A = None
        self.r: A = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
l = C("l")
f = D("f")
e = C("e")
j = D("j")
i = A("i")
c = B("c")

m.p = i
m.u = i
m.r = i
n.w = m
n.x = c
n.p = i
l.p = e
l.q = e
l.x = e
l.r = f
f.v = j
e.p = l
e.q = l
e.x = l
e.r = f
j.v = f
i.p = m
i.u = m
i.r = m
c.w = i
c.x = n
c.p = m
assert l.q.q.q.r.txt == "f"