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

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

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

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

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

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

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

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

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

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

h.y = b
j.p = m
j.v = m
j.t = a
j.q = c
b.x = j
b.v = i
m.y = j
m.r = c
a.y = j
a.r = c
n.y = j
n.r = c
l.y = j
l.r = b
i.y = b
c.x = j
c.v = i
assert j.p.r.x.q.v.y.x.txt == "j"