class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
g = C("g")
b = A("b")
e = A("e")
j = C("j")
f = B("f")

m.s = f
m.x = f
m.y = h
h.q = f
g.o = j
g.p = h
b.s = f
b.y = f
b.x = h
e.s = h
e.x = h
e.y = f
j.o = g
j.p = h
f.q = h
assert j.p.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
g = C("g")
b = A("b")
e = A("e")
j = C("j")
f = B("f")

m.s = f
m.x = f
m.y = h
h.q = f
g.o = j
g.p = h
b.s = f
b.y = f
b.x = h
e.s = h
e.x = h
e.y = f
j.o = g
j.p = h
f.q = h
assert j.p.q.q.q.txt == "f"