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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: D = None
        self.r: B = None
        self.o: B = None
        self.txt = txt

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

l = A("l")
a = B("a")
i = C("i")
d = D("d")
c = D("c")

l.v = i
l.q = i
l.p = a
a.t = d
a.p = c
i.t = l
i.q = c
i.r = a
i.o = a
d.p = c
d.v = c
d.t = l
d.s = l
c.p = d
c.v = d
c.t = l
c.s = l
assert c.t.p.p.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: D = None
        self.r: B = None
        self.o: B = None
        self.txt = txt

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

l = A("l")
a = B("a")
i = C("i")
d = D("d")
c = D("c")

l.v = i
l.q = i
l.p = a
a.t = d
a.p = c
i.t = l
i.q = c
i.r = a
i.o = a
d.p = c
d.v = c
d.t = l
d.s = l
c.p = d
c.v = d
c.t = l
c.s = l
assert c.t.p.p.p.v.txt == "c"