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

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

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

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

j = A("j")
m = B("m")
i = C("i")
f = D("f")
b = A("b")
c = D("c")

j.y = f
j.q = b
j.r = i
j.v = m
m.p = i
m.s = i
m.q = i
m.y = j
i.t = m
f.p = b
b.y = c
b.q = j
b.r = i
b.v = m
c.p = b
assert j.q.r.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: A = None
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
i = C("i")
f = D("f")
b = A("b")
c = D("c")

j.y = f
j.q = b
j.r = i
j.v = m
m.p = i
m.s = i
m.q = i
m.y = j
i.t = m
f.p = b
b.y = c
b.q = j
b.r = i
b.v = m
c.p = b
assert j.q.r.t.q.t.txt == "m"