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

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

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

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

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

f.q = i
b.q = d
b.s = h
b.u = k
b.t = l
d.w = m
d.r = m
d.v = h
k.t = f
k.p = b
k.y = b
k.o = a
a.q = m
a.s = b
a.u = k
a.t = i
l.q = i
i.q = f
h.q = m
h.s = a
h.u = k
h.t = f
m.w = d
m.r = d
m.v = h
assert i.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

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

f.q = i
b.q = d
b.s = h
b.u = k
b.t = l
d.w = m
d.r = m
d.v = h
k.t = f
k.p = b
k.y = b
k.o = a
a.q = m
a.s = b
a.u = k
a.t = i
l.q = i
i.q = f
h.q = m
h.s = a
h.u = k
h.t = f
m.w = d
m.r = d
m.v = h
assert i.q.q.q.txt == "f"