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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

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

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

b.q = i
b.v = k
b.r = h
b.o = g
g.p = i
g.z = i
h.o = i
h.w = c
k.p = g
c.p = h
c.z = i
d.q = i
d.v = k
d.r = h
d.o = g
i.o = h
i.w = c
j.q = i
j.v = k
j.r = h
j.o = c
f.q = h
f.r = h
f.v = k
f.o = c
assert c.z.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.r: C = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

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

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

b.q = i
b.v = k
b.r = h
b.o = g
g.p = i
g.z = i
h.o = i
h.w = c
k.p = g
c.p = h
c.z = i
d.q = i
d.v = k
d.r = h
d.o = g
i.o = h
i.w = c
j.q = i
j.v = k
j.r = h
j.o = c
f.q = h
f.r = h
f.v = k
f.o = c
assert c.z.w.z.w.txt == "c"