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

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

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

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

j = A("j")
f = B("f")
h = C("h")
m = D("m")
c = D("c")
n = C("n")

j.q = f
j.r = f
j.t = m
j.y = m
f.w = j
f.o = j
f.z = j
h.p = n
h.r = n
h.t = n
m.o = j
m.v = c
c.o = j
c.v = m
n.p = h
n.r = h
n.t = h
assert f.w.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: D = None
        self.r: B = None
        self.y: D = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
h = C("h")
m = D("m")
c = D("c")
n = C("n")

j.q = f
j.r = f
j.t = m
j.y = m
f.w = j
f.o = j
f.z = j
h.p = n
h.r = n
h.t = n
m.o = j
m.v = c
c.o = j
c.v = m
n.p = h
n.r = h
n.t = h
assert f.w.y.o.txt == "j"