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

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

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

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

j = A("j")
n = B("n")
m = C("m")
e = D("e")
b = B("b")
h = A("h")
c = A("c")

j.y = b
j.o = m
j.r = m
j.q = m
n.w = b
m.o = e
m.x = c
e.x = n
b.w = n
h.y = n
h.o = m
h.r = m
h.q = m
c.y = b
c.o = m
c.r = m
c.q = m
assert j.y.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: C = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

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

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

j = A("j")
n = B("n")
m = C("m")
e = D("e")
b = B("b")
h = A("h")
c = A("c")

j.y = b
j.o = m
j.r = m
j.q = m
n.w = b
m.o = e
m.x = c
e.x = n
b.w = n
h.y = n
h.o = m
h.r = m
h.q = m
c.y = b
c.o = m
c.r = m
c.q = m
assert j.y.w.w.txt == "b"