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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: A = None
        self.x: A = None
        self.p: A = None
        self.txt = txt

l = A("l")
k = B("k")
h = C("h")
a = D("a")
c = D("c")
j = D("j")
b = A("b")
i = A("i")

l.q = h
l.t = c
k.s = h
k.x = a
k.y = i
h.v = k
a.z = i
a.q = i
a.x = i
a.p = l
c.z = l
c.q = l
c.x = l
c.p = b
j.z = b
j.p = b
j.q = l
j.x = i
b.q = h
b.t = c
i.q = h
i.t = j
assert a.z.q.v.y.q.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: A = None
        self.x: A = None
        self.p: A = None
        self.txt = txt

l = A("l")
k = B("k")
h = C("h")
a = D("a")
c = D("c")
j = D("j")
b = A("b")
i = A("i")

l.q = h
l.t = c
k.s = h
k.x = a
k.y = i
h.v = k
a.z = i
a.q = i
a.x = i
a.p = l
c.z = l
c.q = l
c.x = l
c.p = b
j.z = b
j.p = b
j.q = l
j.x = i
b.q = h
b.t = c
i.q = h
i.t = j
assert a.z.q.v.y.q.v.x.txt == "a"