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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

g = A("g")
a = B("a")
l = C("l")
i = D("i")
c = D("c")
m = B("m")
h = A("h")
k = C("k")

g.p = l
g.q = k
g.w = k
a.x = i
a.w = c
l.p = c
i.t = l
c.t = l
m.x = i
m.w = c
h.p = k
h.w = k
h.q = l
k.p = c
assert g.q.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: C = None
        self.w: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

g = A("g")
a = B("a")
l = C("l")
i = D("i")
c = D("c")
m = B("m")
h = A("h")
k = C("k")

g.p = l
g.q = k
g.w = k
a.x = i
a.w = c
l.p = c
i.t = l
c.t = l
m.x = i
m.w = c
h.p = k
h.w = k
h.q = l
k.p = c
assert g.q.p.t.txt == "l"