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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

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

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

g.x = j
c.s = f
c.p = j
j.u = l
j.r = g
j.s = g
f.p = i
h.s = f
h.p = j
l.s = i
l.p = j
i.p = b
e.s = f
e.p = j
k.s = b
k.p = j
b.p = f
assert k.p.u.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

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

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

g.x = j
c.s = f
c.p = j
j.u = l
j.r = g
j.s = g
f.p = i
h.s = f
h.p = j
l.s = i
l.p = j
i.p = b
e.s = f
e.p = j
k.s = b
k.p = j
b.p = f
assert k.p.u.p.s.txt == "g"