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

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: A = None
        self.s: C = None
        self.txt = txt

m = A("m")
j = B("j")
c = C("c")
a = D("a")
l = A("l")
n = B("n")

m.t = c
j.r = c
j.q = c
j.x = l
j.p = l
c.v = l
c.w = m
a.z = n
a.q = l
a.s = c
l.t = c
n.r = c
n.q = c
n.x = m
n.p = l
assert c.w.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: A = None
        self.s: C = None
        self.txt = txt

m = A("m")
j = B("j")
c = C("c")
a = D("a")
l = A("l")
n = B("n")

m.t = c
j.r = c
j.q = c
j.x = l
j.p = l
c.v = l
c.w = m
a.z = n
a.q = l
a.s = c
l.t = c
n.r = c
n.q = c
n.x = m
n.p = l
assert c.w.t.w.t.w.txt == "m"