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

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

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

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

l = A("l")
a = B("a")
b = C("b")
h = D("h")
n = D("n")

l.p = b
a.o = l
a.z = l
a.t = h
b.o = h
b.q = a
b.x = l
h.v = l
n.v = l
assert n.v.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
b = C("b")
h = D("h")
n = D("n")

l.p = b
a.o = l
a.z = l
a.t = h
b.o = h
b.q = a
b.x = l
h.v = l
n.v = l
assert n.v.p.q.txt == "a"