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

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

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

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

f = A("f")
h = B("h")
e = C("e")
d = D("d")
b = C("b")
m = D("m")
i = A("i")
j = D("j")

f.r = i
f.p = d
f.s = d
h.o = m
h.s = f
h.z = e
e.v = i
e.p = h
e.y = h
d.q = m
d.p = h
d.x = b
d.v = j
b.v = f
b.p = h
b.y = h
m.q = d
m.p = h
m.x = b
m.v = j
i.r = f
i.p = j
i.s = m
j.q = m
j.v = m
j.p = h
j.x = e
assert j.q.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: D = None
        self.s: D = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
e = C("e")
d = D("d")
b = C("b")
m = D("m")
i = A("i")
j = D("j")

f.r = i
f.p = d
f.s = d
h.o = m
h.s = f
h.z = e
e.v = i
e.p = h
e.y = h
d.q = m
d.p = h
d.x = b
d.v = j
b.v = f
b.p = h
b.y = h
m.q = d
m.p = h
m.x = b
m.v = j
i.r = f
i.p = j
i.s = m
j.q = m
j.v = m
j.p = h
j.x = e
assert j.q.q.v.txt == "j"