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

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

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

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

f = A("f")
h = B("h")
g = C("g")
d = D("d")
j = D("j")
a = B("a")
n = B("n")
c = B("c")
k = D("k")

f.y = g
h.o = d
h.q = f
h.p = f
h.y = n
g.w = f
g.z = n
d.q = f
d.v = f
j.q = f
j.v = f
a.o = d
a.q = f
a.p = f
a.y = n
n.o = d
n.q = f
n.p = f
n.y = h
c.o = j
c.q = f
c.p = f
c.y = a
k.q = f
k.v = f
assert j.v.y.z.o.v.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
g = C("g")
d = D("d")
j = D("j")
a = B("a")
n = B("n")
c = B("c")
k = D("k")

f.y = g
h.o = d
h.q = f
h.p = f
h.y = n
g.w = f
g.z = n
d.q = f
d.v = f
j.q = f
j.v = f
a.o = d
a.q = f
a.p = f
a.y = n
n.o = d
n.q = f
n.p = f
n.y = h
c.o = j
c.q = f
c.p = f
c.y = a
k.q = f
k.v = f
assert j.v.y.z.o.v.y.z.y.txt == "h"