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

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

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

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

h = A("h")
b = B("b")
f = C("f")
m = D("m")
k = B("k")
i = A("i")
l = D("l")
j = D("j")

h.q = f
h.v = b
h.w = b
b.x = f
b.q = f
b.t = i
f.u = i
f.r = k
f.t = j
m.r = i
m.z = i
k.x = f
k.q = f
k.t = h
i.q = f
i.v = b
i.w = k
l.r = h
l.z = h
j.r = h
j.z = i
assert f.t.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
f = C("f")
m = D("m")
k = B("k")
i = A("i")
l = D("l")
j = D("j")

h.q = f
h.v = b
h.w = b
b.x = f
b.q = f
b.t = i
f.u = i
f.r = k
f.t = j
m.r = i
m.z = i
k.x = f
k.q = f
k.t = h
i.q = f
i.v = b
i.w = k
l.r = h
l.z = h
j.r = h
j.z = i
assert f.t.z.q.txt == "f"