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

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

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

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

b = A("b")
n = B("n")
h = C("h")
a = D("a")
i = A("i")
j = B("j")
c = C("c")

b.w = i
n.z = a
n.q = a
n.o = j
h.x = b
h.p = i
a.s = i
a.z = b
i.w = b
j.z = a
j.q = a
j.o = n
c.x = i
c.p = b
assert b.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

b = A("b")
n = B("n")
h = C("h")
a = D("a")
i = A("i")
j = B("j")
c = C("c")

b.w = i
n.z = a
n.q = a
n.o = j
h.x = b
h.p = i
a.s = i
a.z = b
i.w = b
j.z = a
j.q = a
j.o = n
c.x = i
c.p = b
assert b.w.w.w.w.w.w.w.txt == "i"