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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

c.r = n
c.s = m
a.v = i
a.w = n
b.y = a
i.s = m
i.p = b
i.q = b
i.t = c
n.r = c
n.s = c
m.r = c
m.s = n
j.s = m
j.p = b
j.q = b
j.t = c
assert i.t.s.s.txt == "n"