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

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

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

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

b = A("b")
k = B("k")
d = C("d")
m = D("m")
c = D("c")
h = C("h")
i = A("i")
n = D("n")
f = B("f")
j = D("j")

b.w = k
b.u = k
k.r = f
d.q = m
d.p = b
m.v = d
m.q = d
m.w = c
c.v = h
c.q = h
c.w = j
h.q = j
h.p = i
i.w = f
i.u = f
n.v = d
n.q = d
n.w = c
f.r = k
j.v = h
j.q = h
j.w = n
assert h.q.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
d = C("d")
m = D("m")
c = D("c")
h = C("h")
i = A("i")
n = D("n")
f = B("f")
j = D("j")

b.w = k
b.u = k
k.r = f
d.q = m
d.p = b
m.v = d
m.q = d
m.w = c
c.v = h
c.q = h
c.w = j
h.q = j
h.p = i
i.w = f
i.u = f
n.v = d
n.q = d
n.w = c
f.r = k
j.v = h
j.q = h
j.w = n
assert h.q.w.w.w.txt == "j"