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

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

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

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

n = A("n")
h = B("h")
l = C("l")
c = D("c")

n.t = c
n.v = c
n.p = h
n.y = h
h.r = l
h.t = l
h.p = c
h.y = c
l.o = h
c.q = l
assert n.v.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: B = None
        self.v: D = None
        self.y: B = None
        self.txt = txt

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

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

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

n = A("n")
h = B("h")
l = C("l")
c = D("c")

n.t = c
n.v = c
n.p = h
n.y = h
h.r = l
h.t = l
h.p = c
h.y = c
l.o = h
c.q = l
assert n.v.q.o.txt == "h"