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

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

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

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

k = A("k")
n = B("n")
i = C("i")
l = D("l")
h = B("h")
j = D("j")
m = B("m")

k.x = i
n.x = i
i.y = j
l.q = n
h.x = i
j.q = m
m.x = i
assert i.y.q.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
i = C("i")
l = D("l")
h = B("h")
j = D("j")
m = B("m")

k.x = i
n.x = i
i.y = j
l.q = n
h.x = i
j.q = m
m.x = i
assert i.y.q.x.y.txt == "j"