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

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

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

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

n = A("n")
h = B("h")
k = C("k")
d = D("d")
j = D("j")

n.y = h
h.v = n
h.o = n
h.s = n
h.q = n
k.t = n
d.x = h
j.x = h
assert k.t.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

n = A("n")
h = B("h")
k = C("k")
d = D("d")
j = D("j")

n.y = h
h.v = n
h.o = n
h.s = n
h.q = n
k.t = n
d.x = h
j.x = h
assert k.t.y.s.txt == "n"